import { Alova } from '@/utils/http/alova/index';

// 定义数据模型接口
export interface CabineModelItem {
  modelId: string;
  modelName: string;
  prodFactory: string;
  workingVoltage: string;
  batteryLife: number;
  workingTemperature: string;
  ipRating: string;
  remark: string;
  createTime: string;
  createName: string;
  createId: string;
  openingMode?: string;
  openingModeName?: string;
  storageLayout?: string;
  storageShoes?: number;
}

export interface CabineModelParams {
  modelName?: string;
  currentPage: number;
  pageSize: number;
}

export interface CabineModelPageResult {
  records: CabineModelItem[];
  total: number;
  size: number;
  current: number;
  pages: number;
  orders: any[];
  optimizeCountSql: boolean;
  searchCount: boolean;
  countId: null;
  maxLimit: null;
}

// 定义通用响应结构
export interface ApiResponse<T> {
  code: number;
  sucMsg: string;
  errMsg: string;
  encrypt: boolean;
  data: T;
}

export const baseApi = '/web/eqCabinetModel';

/**
 * @description: 获取铁鞋型号分页列表
 */
export function getCabineModelList(params: CabineModelParams) {
  return Alova.Post<ApiResponse<CabineModelPageResult>>(
    `${baseApi}/page`, 
    { params }
  );
}

/**
 * @description: 新增铁鞋型号
 */
export function addCabineModel(params: any) {
  return Alova.Post<ApiResponse<boolean>>(
    `${baseApi}/add`, 
    { params }
  );
}

/**
 * @description: 更新铁鞋型号
 */
export function updateCabineModel(params: any) {
  return Alova.Post<ApiResponse<boolean>>(
    `${baseApi}/update`, 
    { params }
  );
}

/**
 * @description: 删除型号
 */
export function deleteCabineModel(params: { modelId: string }) {
  return Alova.Post<ApiResponse<boolean>>(
    `${baseApi}/delete`, 
    { params }
  );
}

/**
 * @description: 批量删除型号
 */
export function batchDeleteCabineModel(params: { ids: string[] }) {
  return Alova.Post<ApiResponse<boolean>>(
    `${baseApi}/dels`, 
    { params }
  );
}

/**
 * @description: 校验型号名称是否存在
 */
export function validateModelName(params: { modelName: string; modelId?: string }) {
  return Alova.Post<ApiResponse<boolean>>(
    `${baseApi}/validateModelName`,
    { params }
  );
}

/**
 * @description: 获取开启方式选项
 */
export function getOpeningModeOptions() {
  return Alova.Post<ApiResponse<{ name: string; value: string }[]>>(
    `${baseApi}/validateModelName`,
    { params }
  );
}
